package com.firmboy.search.collection;

import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * map1.7测试类
 *
 * @author firmboy
 * @create 2018-05-06 上午11:04
 **/
public class HashMapTest {

    private static HashMap map = new HashMap();

    //private static ConcurrentHashMap map = new ConcurrentHashMap();

    @Test
    public void hashMapTest(){

        Runnable run = new Runnable() {
            @Override
            public void run() {
                while (true){
                    map.put(System.currentTimeMillis(),"1");

                }
            }
        };

        Thread thread = new Thread(run);
        thread.start();


        while (true){
            System.out.println("map的容量："+map.size());
            try {
                Thread.sleep(1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

    @Test
    public void test1(){
        map.put(System.currentTimeMillis(),"1");
    }
}
